﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using PreguntaAlExperto.DataFramework;
using PreguntaAlExperto.RulesLayer.Entities;
using PreguntaAlExperto.TransporterObjectsFramework;
using PreguntaAlExperto.RulesLayer.ObjectMapper.Contracts;

namespace PreguntaAlExperto.ObjectMapper.DTO
{
    internal class SiteMapDTO
        : BaseDTO
    {
        public object Select(string query, SearchCriteria searchCriteria)
        {
            DataAccess dataAccess = new DataAccess();
            BaseList<SiteMap> _transporter = new BaseList<SiteMap>();

            foreach (object rawEntity in dataAccess.Select(query, searchCriteria))
            {
                SiteMap _siteMap = new SiteMap();
                _siteMap.loc = ((ArrayList)rawEntity)[0].ToString();
                _siteMap.lastmod = ((DateTime)((ArrayList)rawEntity)[1]);
                _transporter.Add(_siteMap);
            }
            _transporter.TotalRecords = dataAccess.getRecordsAfected;
            return _transporter;
        }
    }
}
